package org.mbds.wolf.seql;
import java.util.ArrayList;
import java.util.List;

import org.simpleframework.xml.ElementList;
import org.simpleframework.xml.Root;

/**
 * 
 * @author alesas
 *
 */
@Root
public class SeqlApplets {
	
	@ElementList
	List<AppletModel> applets = new ArrayList<AppletModel>();

	/**
	 * getApplets
	 * @return applets List
	 */
	public List<AppletModel> getApplets() {
		return applets;
	}

	/**
	 * setApplets
	 * @param applets List
	 */
	public void setApplets(List<AppletModel> applets) {
		this.applets = applets;
	} 
	
	/**
	 * add
	 * @param applet
	 */
	public void add(AppletModel applet){
		this.applets.add(applet);
	}
	
	/**
	 * remove
	 * @param applet
	 */
	public void remove(AppletModel applet){
		this.applets.remove(applet);
	}
	
	/**
	 * getAppletByAlias
	 * @param alias
	 * @return AppletModel
	 */
	public AppletModel getAppletByAlias(String alias){
		if (getApplets() == null)
			return null;
		for (AppletModel applet : getApplets()){
			if (applet.getAlias().equalsIgnoreCase(alias)) {
				System.out.println("Applet: " + applet.getAID() + "  " + alias); 
				return applet;
			}
		}
		return null;
	}
	
	/**
	 * getAppletByAID
	 * @param AID
	 * @return AppletModel
	 */
	public AppletModel getAppletByAID(String AID){
		if (getApplets() == null)
			return null;
		for (AppletModel applet : getApplets()){
			if (applet.getAID().equalsIgnoreCase(AID)) {
				System.out.println("Applet: " + AID + "  " + applet.getAlias()); 
				return applet;
			}
		}
		return null;
	}
}
